'\" te
.\"  Copyright 1989 AT&T  Copyright (c) 1998, Sun Microsystems, Inc.  All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH VLFMT 3C "Dec 29, 1996"
.SH NAME
vlfmt \- display error message in standard format and pass to logging and
monitoring services
.SH SYNOPSIS
.LP
.nf
#include <pfmt.h>
#include <stdarg.h>

\fBint\fR \fBvlfmt\fR(\fBFILE *\fR\fIstream\fR, \fBlong\fR \fIflag\fR, \fBconst char *\fR\fIformat\fR, \fBva_list\fR \fIap\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBvlfmt()\fR function is identical to \fBlfmt\fR(3C), except that it is
called with an argument list as defined by \fB<stdarg.h>\fR\&.
.sp
.LP
The <\fBstdarg.h\fR> header defines the type \fBva_list\fR and a set of macros
for advancing through a list of arguments whose number and types may vary. The
\fIap\fR argument is of type \fBva_list\fR. This argument is used with the
<\fBstdarg.h\fR> macros \fBva_start()\fR, \fBva_arg()\fR, and \fBva_end()\fR.
See \fBstdarg\fR(3EXT). The example in the \fBEXAMPLES\fR section below
demonstrates their use with \fBvlfmt()\fR.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBvlfmt()\fR returns the number of bytes
transmitted.  Otherwise, \fB\(mi1\fR is returned if there was a write error to
\fIstream\fR, or \fB\(mi2\fR is returned if unable to log and/or display at
console.
.SH EXAMPLES
.LP
\fBExample 1 \fRUse of \fBvlfmt()\fR to write an \fBerrlog()\fRroutine.
.sp
.LP
The following example demonstrates how \fBvlfmt()\fR could be used to write an
\fBerrlog()\fR routine. The \fBva_alist()\fR macro is used as the parameter
list in a function definition. The \fBva_start(\fR\fIap\fR, .\|.\|.) call,
where \fIap\fR is of type \fBva_list\fR, must be invoked before any attempt to
traverse and access unnamed arguments. Calls to \fBva_arg(\fR\fIap\fR\fB,
\fR\fIatype\fR\fB)\fR traverse the argument list. Each execution of
\fBva_arg()\fR expands to an expression with the value and type of the next
argument in the list \fIap\fR, which is the same object initialized by
\fBva_start()\fR. The \fIatype\fR argument is the type that the returned
argument is expected to be. The \fBva_end(\fR\fIap\fR\fB)\fR macro must be
invoked when all desired arguments have been accessed. The argument list in
\fIap\fR can be traversed again if \fBva_start()\fR is called again after
\fBva_end()\fR.) In the example below, \fBva_arg()\fR is executed first to
retrieve the format string passed to \fBerrlog()\fR. The remaining
\fBerrlog()\fR arguments (\fIarg1\fR, \fIarg2\fR, \fI\&...\fR) are passed to
\fBvlfmt()\fR in the argument \fIap\fR.

.sp
.in +2
.nf
\fB#include <pfmt.h>
#include <stdarg.h>
/*
 *   errlog should be called like
 *         errlog(log_info, format, arg1, ...);
 */
void errlog(long log_info, ...)
{
        va_list ap;
        char *format;
        va_start(ap, );
        format = va_arg(ap, char *);
        (void) vlfmt(stderr, log_info|MM_ERROR, format, ap);
        va_end(ap);
        (void) abort();
}\fR
.fi
.in -2

.SH USAGE
.sp
.LP
Since \fBvlfmt()\fR uses \fBgettxt\fR(3C), it is recommended that \fBvlfmt()\fR
not be used.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR gettxt (3C),
.BR lfmt (3C),
.BR stdarg (3EXT),
.BR attributes (7)
